<!DOCTYPE HTML>
<script src="/js-test-resources/js-test.js"></script>
<script>
description("Navigate while an EventSource reconnect timer is waiting, then have the reconnect timer trigger before the page unloads.");

if (window.testRunner) {
    testRunner.waitUntilDone();
    testRunner.dumpAsText();
}

var navigateWasCalled = false;

function navigate() {
    if (navigateWasCalled)
        return;
    navigateWasCalled = true;
    window.location = "resources/wait-then-notify-done.php";
}

var es = new EventSource("resources/reconnect.php");
es.onerror = function() {
    setTimeout(navigate, 0);
};
</script>
</body>
</html>
